home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / titlemgt / painting.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  2.9 KB  |  81 lines  |  [TEXT/ttxt]

  1. --<<<
  2. -- Filename:
  3. --     PAINTING.SX
  4.  
  5. -- Other Files Required: 
  6. --     GAUGUIN.BMP bitmap image (400 x 300)
  7.  
  8. -- Purpose:
  9. --     Intended to be a simple title which stores bitmaps in a separate library file.
  10. --     A more elaborate version of this program is available as "paintngs.sx"
  11.  
  12. -- Specialized Classes: (none)
  13.  
  14. -- Instructions to User:
  15. --     1. Open this script.  It will create a title file called PAINTING.SXT.
  16. --     2. Open the library script.  It will create a library file called PAINTING.SXL,
  17. --        and its picture will appear in the title, and close the title.
  18. --     3. Quit ScriptX.  Open the newly created title container called PAINTING.SXT 
  19. --        from the operating system.  It should open up the title container and 
  20. --        library container, and display the painting.
  21.  
  22. -- Authors:
  23. --     Erik Neumann, Douglas Kramer
  24.  
  25. ------------------------------------------------------------------------------
  26. -- CREATE THE TITLE **********************************************************
  27. ------------------------------------------------------------------------------
  28. -- Create the window
  29. global myWindow := new Window boundary: (new Rect x1: 0 y1: 40 x2: 400 y2: 300)
  30. myWindow.name := "Gauguin"
  31. show myWindow
  32.  
  33. ------------------------------------------------------------------------------
  34. -- Create and append a TwoDShape to the window
  35. global myShape := new TwoDShape
  36. append myWindow myShape
  37.  
  38. ------------------------------------------------------------------------------
  39. -- Create the title container and add the window to it
  40. global tc := new TitleContainer dir:theScriptDir path:"painting.sxt" \
  41.     name:"Painting Title"
  42. append tc myWindow
  43.  
  44. -- Define the startup action
  45. tc.startupAction := (
  46.     -- Load all objects in the title container
  47.     tc -> forEach tc load undefined
  48.  
  49.     -- Get the library container
  50.     local myLC := chooseOne theOpenContainers \
  51.                     (v a -> v.name = "Painting Library") 0
  52.  
  53.     -- Assign the first bitmap in the library to the target 
  54.     -- of the 2D shape in the frontmost window
  55.     tc.windows[1][1].target := myLC[1]
  56. )
  57.  
  58. ------------------------------------------------------------------------------
  59. -- CREATE THE LIBRARY ********************************************************
  60. ------------------------------------------------------------------------------
  61.  
  62. function getPict fileName -> (
  63.     local myStream := getStream theScriptDir fileName @readable
  64.     local myimage := importMedia theImportExportEngine myStream @image @dib \
  65.         @bitmap colormap:defaultcolormap
  66.     myimage
  67. )
  68.  
  69. global p1 := getPict "GAUGUIN.BMP"
  70.  
  71. ------------------------------------------------------------------------------
  72. -- Create the library, and append the picture to it
  73. -- Note that this library uses the title container tc defined previously
  74. global lc := new LibraryContainer dir:theScriptDir path:"painting.sxl" \
  75.     name:"Painting Library" user:tc
  76. append lc p1
  77.  
  78. -- Close the title container and then the library container
  79. close tc    
  80. close lc
  81.